// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include <stdio.h>
#include "DirectX.h"
#include "GWFuncs.h"

char inifile[MAX_PATH]; // Stores the path to the speed.ini file. This string is loaded on startup of the dll

void Initiate(HMODULE hModule)
{
	GetModuleFileNameA(hModule,inifile,MAX_PATH); // Get the path to where this dll file is stored
	int i = 0;
    while (inifile[i] != '\0') {
		i++;
    }
    while (inifile[i] != '\\') {
		i--;
    }
    inifile[i+1] = 's';
    inifile[i+2] = 'p';
    inifile[i+3] = 'e';
    inifile[i+4] = 'e';
    inifile[i+5] = 'd';
    inifile[i+6] = '.';
    inifile[i+7] = 'i';
    inifile[i+8] = 'n';
    inifile[i+9] = 'i';
    inifile[i+10] = '\0';

	DXSettingsInit();
	Scan();
	D3DInit();
	CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)TextBoxLoop, NULL, 0, NULL); 
}

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
		DisableThreadLibraryCalls((HMODULE)hModule);
		Initiate(hModule);
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		break;
	}
	return TRUE;
}

